Open
Conversation
… involved the first set of user stories.
…/selling with cost.
Author
|
WIP, still not working properly with trade costs, ran out of time, will fix this asap. |
…at I need to do will add asap.
Ada TraderWhat We're Looking For
|
CheezItMan
reviewed
Dec 18, 2017
| buy: true, | ||
| symbol: this.$('select[name=symbol]').val(), | ||
| targetPrice: parseFloat(this.$('input[name=price-target]').val()), | ||
| currentPrice: 0, |
There was a problem hiding this comment.
How is the order to get the current quote price? Maybe this view needs to have an instance variable referring to the Quotelist.
| targetPrice: 50.00, | ||
| }); | ||
|
|
||
| expect(order.isValid()).toEqual(true); |
| action: true, | ||
| }); | ||
|
|
||
| expect(order.isValid()).toEqual(false); |
| else if (!this.buy && this.targetPrice <= this.currentPrice) { | ||
| error.targetPrice = ['Price is lower than market, aim higher!']; | ||
| } | ||
| else if (!attributes.targetPrice) { |
There was a problem hiding this comment.
You also need (based on your tests) to check for numeric value for price, boolean value for buy and maybe check if (!attributes.targetPrice) first.
| const orderData = { | ||
| buy: false, | ||
| symbol: this.$('select[name=symbol]').val(), | ||
| targetPrice: parseFloat(this.$('input[name=price-target]').val()), |
| sellQuote: function() { | ||
| this.model.set('buy', false); | ||
| let tradeTemplate = _.template($('#trade-template').html()); | ||
| $('#trades').prepend(tradeTemplate(this.model.attributes)); |
There was a problem hiding this comment.
You should not directly access jQuery in a view. Instead use this.$ to select things within the view. Since the trades section is not within the view you can can trigger an event and let the larger view handle the prepending.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ada Trader
Congratulations! You're submitting your assignment!
Comprehension Questions